<?php
    /**
     * aheadWorks Co.
     *
     * NOTICE OF LICENSE
     *
     * This source file is subject to the EULA
     * that is bundled with this package in the file LICENSE.txt.
     * It is also available through the world-wide-web at this URL:
     * http://ecommerce.aheadworks.com/LICENSE-M1.txt
     *
     * @category   AW
     * @package    AW_AdvancedReviews
     * @copyright  Copyright (c) 2009-2011 aheadWorks Co. (http://www.aheadworks.com)
     * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
     */
?>
<?php if (Mage::helper('advancedreviews')->checkVersion('1.4.0.0')): ?>
    <?php if($this->getProductData()->getId()): ?>
    <div class="product-review">
        <div class="page-title">
            <h1><?php echo $this->__('Review Details') ?></h1>
        </div>
        <div class="product-img-box">
            <a href="<?php echo $this->getProductData()->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getProductData()->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($this->getProductData(), 'small_image')->resize(125, 125); ?>" height="125" width="125" alt="<?php echo $this->htmlEscape($this->getProductData()->getName()) ?>" /></a>
            <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
                 <p class="label"><?php echo $this->__('Average Customer Rating') ?>:</p>
                 <?php echo $this->getReviewsSummaryHtml($this->getProductData()) ?>
            <?php endif; ?>
        </div>
        <div class="product-details">
            <h2 class="product-name"><?php echo $this->htmlEscape($this->getProductData()->getName()) ?></h2>
            <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
                <h3><?php echo $this->__('Product Rating:') ?></h3>
                <table class="ratings-table">
                <?php foreach ($this->getRating() as $_rating): ?>
                    <?php if($_rating->getPercent()): ?>
                        <tr>
                            <th><?php echo $this->__($_rating->getRatingCode()) ?></th>
                            <td>
                                <div class="rating-box">
                                    <div class="rating" style="width:<?php echo ceil($_rating->getPercent()) ?>%;"></div>
                                </div>
                            </td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
                </table>
                </dl>
            <?php endif; ?>
            <dl>
                <dt>
                    <?php echo $this->__('Product Review (submitted on %s):', $this->dateFormat($this->getReviewData()->getCreatedAt())) ?>
                </dt>
                <dd>
                    <?php echo nl2br($this->htmlEscape($this->getReviewData()->getDetail())) ?>
                </dd>
            </dl>
            <?php
                echo $this->getChild('advancedreviews_proscons_indicator')->setReviewId( $this->getReviewData()->getId() )->toHtml();
                echo $this->getChild('advancedreviews_recommend_indicator')->setReviewId( $this->getReviewData()->getId() )->toHtml();
                echo $this->getChild('advancedreviews_footer')->setReviewId( $this->getReviewData()->getId() )->toHtml();
            ?>
        </div>
        <div class="buttons-set">
            <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Product Reviews') ?></a></p>
        </div>
    </div>
    <?php endif; ?>
<?php else: ?>
    <?php if($this->getProductData()->getId()): ?>
        <div class="page-head">
            <h4><?php echo $this->__('Review Details') ?></h4>
        </div>
        <div class="my-review-detail">
            <div class="product-image">
                <p><a href="<?php echo $this->getProductData()->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProductData(), 'small_image')->resize(125, 125); ?>" alt="<?php echo $this->htmlEscape($this->getProductData()->getName()) ?>" height="100" width="100" /></a></p>
                <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
                    <small><?php echo $this->__('Average Customer Rating') ?>:</small>
                    <?php echo $this->getReviewsSummaryHtml($this->getProductData()) ?>
                <?php endif; ?>
            </div>
        <div class="details">
            <h3><?php echo $this->htmlEscape($this->getProductData()->getName()) ?></h3>
            <?php if( $this->getRating() && $this->getRating()->getSize()): ?>
            <strong><?php echo $this->__('Product Rating:') ?></strong>
                <?php foreach ($this->getRating() as $_rating): ?>
                <?php if($_rating->getPercent()): ?>
                    <div class="ratings">
                       <?php echo $this->__($_rating->getRatingCode()) ?>
                        <div class="rating-box">
                            <div class="rating" style="width:<?php echo ceil($_rating->getPercent()) ?>%;"></div>
                        </div>
                    </div>
                <?php endif; ?>
                <?php endforeach; ?>
            <?php endif; ?>
            <div class="clear"></div>
            <?php echo $this->__('Product Review (submitted on %s):', $this->dateFormat($this->getReviewData()->getCreatedAt())) ?>
                <div class="description">
                    <p><?php echo nl2br($this->htmlEscape($this->getReviewData()->getDetail())) ?></p>
                    <?php
                        echo $this->getChild('advancedreviews_proscons_indicator')->setReviewId( $this->getReviewData()->getId() )->toHtml();
                        echo $this->getChild('advancedreviews_recommend_indicator')->setReviewId( $this->getReviewData()->getId() )->toHtml();
                        echo $this->getChild('advancedreviews_footer')->setReviewId( $this->getReviewData()->getId() )->toHtml();
                    ?>
                </div>
        </div></div>
        <div class="button-set"><a href="<?php echo $this->getBackUrl() ?>" class="left">&laquo; <?php echo $this->__('Back to Product Reviews') ?></a></div><br />
    <?php endif; ?>
<?php endif; ?>
